const Flow = require("../Flow");
const Player = require("../Player");
const Card = require("../Card");
const PLAYER_LIST = ["player1", "player2", "player3", "player4"].map(
	username => new Player({ nickname: username })
);

const FLOW = new Flow(PLAYER_LIST);

const [player_1, player_2, player_3, player_4] = PLAYER_LIST;

[
	"梅花_Q 红心_Q 黑桃_1 方块_4 黑桃_6 梅花_K 梅花_J 方块_J 红心_10 黑桃_10 方块_Q 黑桃_Q 红心_K",
	"梅花_Q 红心_Q 黑桃_1 方块_4 黑桃_6 梅花_K 梅花_J 方块_J 红心_10 黑桃_10 方块_Q 黑桃_Q 红心_K",
	"梅花_Q 红心_Q 黑桃_1 梅花_J 红心_J 梅花_K 红心_K 方块_8 方块_9 黑桃_10 黑桃_9 黑桃_8 黑桃_K",
	"黑桃_1 黑桃_2 黑桃_3 黑桃_4 黑桃_5 黑桃_6 红心_7 黑桃_8 黑桃_9 黑桃_10 黑桃_J 黑桃_Q 黑桃_K"
].forEach((cards, i) => {
	const player = PLAYER_LIST[i];
	if (i < 2) {
		//0,1
		player.removeCards(player.card_list);
		player.addCards(cards.split(" ").map(txt => Card.getIns(txt)));
		FLOW.playerSubmitRes(player, {
			top: "梅花_J 方块_J 黑桃_1".split(" "),
			mid: "方块_4 黑桃_6 梅花_K 梅花_Q 红心_Q".split(" "),
			btm: "红心_10 黑桃_10 方块_Q 黑桃_Q 红心_K".split(" ")
		});
	} else {
		//2,3
		player.removeCards(player.card_list);
		player.addCards(cards.split(" ").map(txt => Card.getIns(txt)));
		FLOW.playerSubmitRes(player, {
			type: i==2?"all_big":"one_long",
			all: cards.split(" ") //player_3.card_list.map(card => card.toString())
		});
	}
});
const results_list = FLOW.calculateResults();
console.log(JSON.stringify(results_list.map(results=>results.total),null,2));
